package com.gougou.manager.web.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.gougou.manager.pojo.TbItemParamItem;
import com.gougou.manager.service.MPTbItemParamItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 商品规格和商品的关系表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2018-09-07
 */
@RestController
@RequestMapping("/tbItemParamItem")
public class TbItemParamItemController {

    @Autowired
    private MPTbItemParamItemService mpTbItemParamItemService;

    /***************************************
     * 查询规格参数信息
     * @param id
     * @return
     * *************************************
     */
    @RequestMapping("/query/{id}")
    public HashMap<Object, Object> QueryItemParamItem(@PathVariable Integer id){
        HashMap<Object, Object> objectObjectHashMap = new HashMap<Object, Object>();
        try {
            EntityWrapper<TbItemParamItem> tbItemParamItemEntityWrapper = new EntityWrapper<TbItemParamItem>();
            tbItemParamItemEntityWrapper.where("item_id={0}",id);

            List<TbItemParamItem> list = mpTbItemParamItemService.selectList(tbItemParamItemEntityWrapper);

            if(list==null || list.size()==0){
                objectObjectHashMap.put("code","400");
                return objectObjectHashMap;
            }else{
                objectObjectHashMap.put("code","200");
                objectObjectHashMap.put("data",list);
                return objectObjectHashMap;
            }
        }catch (Exception e) {
            e.printStackTrace();
            objectObjectHashMap.put("code","500");
            return objectObjectHashMap;
        }

    }
}

